<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/8/19 0019
 * Time: 14:22
 */

namespace app\currency\controller;


use library\Controller;
use think\Db;

/**
 * 阿姨提交地址
 * Class CleanerAddress
 * @package app\currency\controller
 */
class CleanerAddress extends Controller
{
    protected $table = 'CleanerAddress';

    /**
     * 列表
     * @menu true
     * @auth true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $this->title = '信息列表';
        $where = [['status','egt','0']];
        $this->_query($this->table)
            ->where($where)
            ->like('address')
            ->equal('status')
            ->dateBetween('create_at')
            ->order('status asc,create_at desc')->page();
    }
    protected function _index_page_filter(&$data)
    {
        $cids = array_unique(array_column($data, 'cid'));
        $cleanerList = Db::name('Cleaner')->whereIn('id', $cids)->select();
        foreach ($data as &$vo) {
            $vo['cleaner'] = [];
            foreach ($cleanerList as $cleaner) if ($cleaner['id'] === $vo['cid']) {
                $vo['cleaner'] = $cleaner;
            }
        }
    }
    /**
     * 通过请求
     * @auth true
     */
    public function resume()
    {

        $this->applyCsrfToken();
        $this->_save($this->table, ['status' => '1']);
    }
}